<div class="layui-card">
  <div class="layadmin-search">
    <form class="layui-form" method="post" lay-filter="form_invite_search" id="filterForm">
      <script type="text/html" template lay-done="layui.data.done(d.params)">
        <a class="layui-btn layui-table-link"
           target="_blank"
           href="agent-admin/convert_formulas/{{d.params.id}}/records_export?token={{layui.admin.getAccessToken()}}">
          <i class="layui-icon layui-icon-add-1"></i>合成记录导出
        </a>
      </script>
    </form>
  </div>
  <div class="layui-card-body">
    <div id="table_records"></div>
    <script type="text/html" id="tpl_convert_status">
      {{d.status.description}}
    </script>
    <script type="text/html" id="tpl_convert_user">
      {{# if (d.user  && d.user.auth ) { }}
      {{d.user.auth.real_name}}
      {{# } else { }}
      {{d.user.mobile}}
      {{# } }}
    </script>
    <script type="text/html" id="tpl_convert_user_mobile">
      {{d.user.mobile}}
    </script>
  </div>
</div>

<script>
  layui.data.done = function (obj) {
    layui.use(['table'], function () {
      let $ = layui.$
        , table = layui.table

      let resourceUrl = 'agent-admin/convert_formulas/' + obj.id + '/records';

      // 列表查询
      table.render({
        elem: '#table_records'
        , url: resourceUrl
        , page: true
        , cols: [[
          {title: '合成用户', templet: '#tpl_convert_user', minWidth: 100}
          , {title: '手机号',  templet: '#tpl_convert_user_mobile', minWidth: 100}
          , {title: '合成数量', field: 'convert_count', width: 180, align: "center"}
          , {title: '合成时间', field: 'created_at', width: 180, align: "center"}
          , {title: '状态', templet: '#tpl_convert_status', width: 100, align: "center"}
        ]]
      });
    })
  }
</script>

